namespace Sustainalytics.Portfolios.Service.Models
{
    using Sustainalytics.Entities;
    using Sustainalytics.Portfolios.BL;

    public class PortfolioDtoCreator
    {
        private readonly PortfolioDtoFactory[] _factories;

        public PortfolioDtoCreator(ISubscribeToPortfolioManagement subscriptionManager)
        {
            this._factories = new PortfolioDtoFactory[]
                                  {
                                      new PortfolioBaseDtoFactory(), 
                                      new FullDetailsPortfolioFactory(subscriptionManager)
                                  };
        }

        public PortfolioBase Create(Portfolio portfolio, string username, bool includeAll)
        {
            return includeAll
                       ? this._factories[1].Create(portfolio, username)
                       : this._factories[0].Create(portfolio, username);
        }
    }
}